package com.chk.article.service.impl;

import com.chk.commom.utils.CommonResult;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

@RefreshScope
@Service
public class FileService {
    @Value("${qiniu.accessKey}")
    private String QINIU_AK;
    @Value("${qiniu.secretKey}")
    private String QINIU_SK;
    @Value("${qiniu.bucket}")
    private String QINIU_BUCKET;

    //获取七牛云上传token
    public CommonResult getUpToken() {
        Auth auth = Auth.create(QINIU_AK, QINIU_SK);
        String upToken = auth.uploadToken(QINIU_BUCKET);
        return CommonResult.okResult(upToken);
    }
}
